package com.vinxin.app.controller

import com.vinxin.app.model.*
import com.vinxin.app.service.JobhunterService
import com.vinxin.app.utils.DataUtils
import jakarta.servlet.http.HttpServletRequest
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.web.bind.annotation.*

@RestController
@RequestMapping("/jobhunter")
class JobhunterController {
    @Autowired
    private lateinit var jobhunterService: JobhunterService

    @GetMapping("/list")
    fun getList(payload: JobhunterListPayload, request: HttpServletRequest): ResponseModel<List<JobhunterVo>> {
        return ResponseModel.ok(jobhunterService.getList(payload, DataUtils.map2HttpHeaders(DataUtils.extractHeaders(request))))
    }

    @PostMapping("/chat")
    fun triggerChat(@RequestBody payload: TriggerChatPayload, request: HttpServletRequest): ResponseModel<String> {
        return ResponseModel.ok(jobhunterService.triggerChat(payload, DataUtils.map2HttpHeaders(DataUtils.extractHeaders(request))))
    }

    @GetMapping("/chat/used")
    fun getTriggerChatUsed(request: HttpServletRequest): ResponseModel<String?> {
        return ResponseModel.ok(jobhunterService.getTriggerChatUsed(DataUtils.map2HttpHeaders(DataUtils.extractHeaders(request))))
    }

    @GetMapping("/filter/keyword1/{jobId}")
    fun getFilterKeyword1(request: HttpServletRequest, @PathVariable jobId: String): ResponseModel<List<SelectorVo>> {
        return ResponseModel.ok(jobhunterService.getFilterKeyword1(DataUtils.map2HttpHeaders(DataUtils.extractHeaders(request)), jobId))
    }
}